# coding:utf-8
from selenium import webdriver
import time


class Wbtongcheng:
    def __init__(self):
        self.url = 'http://sh.58.com'
        self.driver = None

    def run(self):
        self.driver = webdriver.Chrome()
        self.driver.get(self.url)
        _el = self.driver.find_element_by_xpath('//a[@tongji_tag="pc_home_fc_1_1"]')
        _el.click()
        print(self.driver.current_url)
        _window_list = self.driver.window_handles
        print(_window_list)
        self.driver.switch_to.window(_window_list[1])
        print(self.driver.current_url)
        time.sleep(3)

    def __del__(self):
        self.driver.close()


def main():
    wbtc = Wbtongcheng()
    wbtc.run()


if __name__ == '__main__':
    main()
